#ifndef __ACCEPTOR_H_
#define __ACCEPTOR_H_
#include"Socket.h"
#include"Address.h"
#include<string>
#include"../../libs/Mylog.h"

using std::string;

namespace SC
{
    class Acceptor
    {
    public:
        Acceptor(const unsigned short port);
        Acceptor(const string& ip, const unsigned short port);
        Acceptor(const sockaddr_in& addr);
        
        //Func
        void Start();    // socket, bind(), listen(), accept(). All Processes
        int Cfd();   // get connectfd
        int fd();
    private:
        void reuseAddr(bool flag);
        void reusePort(bool flag);
        void Bind();
        void Listen(int size);

    private:
        Socket _sock;
        Address _addr;
    };

}

#endif